Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust: Use i64 for internal unix timestamps #842

Merged
merged 1 commit into from
Nov 21, 2024

Conversation

bdrung
Copy link
Contributor

@bdrung bdrung commented Sep 5, 2024

pendulum 3.0.0 fails to build on 32-bit armhf:

error: this arithmetic operation will overflow
  --> src/helpers.rs:59:20
   |
59 | seconds += ((146_097 - 10957) * SECS_PER_DAY as usize) as isize;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `135140_usize * 86400_usize`, which would overflow
   |
   = note: `#[deny(arithmetic_overflow)]` on by default

(146_097 - 10957) * SECS_PER_DAY equals 11,676,096,000 which does not fit into 32 bit integers.

Use i64 for the seconds variable while handling with the timestamp. Only convert in to usize once the timestamp is split into its components.

Fixes #784

Pull Request Check List

  • Added tests for changed code.
  • Updated documentation for changed code.

Copy link

codspeed-hq bot commented Sep 22, 2024

CodSpeed Performance Report

Merging #842 will not alter performance

Comparing bdrung:32-bit (f2b0351) with master (83db0b9)

Summary

✅ 1 untouched benchmarks

@Secrus
Copy link
Collaborator

Secrus commented Sep 22, 2024

Thank you for your patch.

@Secrus
Copy link
Collaborator

Secrus commented Nov 21, 2024

Please rebase your changes with master to fix the failing pipeline

pendulum 3.0.0 fails to build on 32-bit armhf:

```
error: this arithmetic operation will overflow
  --> src/helpers.rs:59:20
   |
59 | seconds += ((146_097 - 10957) * SECS_PER_DAY as usize) as isize;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `135140_usize * 86400_usize`, which would overflow
   |
   = note: `#[deny(arithmetic_overflow)]` on by default
```

`(146_097 - 10957) * SECS_PER_DAY` equals 11,676,096,000 which does not
fit into 32 bit integers.

Use i64 for the seconds variable while handling with the timestamp. Only
convert in to `usize` once the timestamp is split into its components.

Fixes #784
Ubuntu-Bug: https://bugs.launchpad.net/ubuntu/+source/pendulum/+bug/2079029
@bdrung
Copy link
Contributor Author

bdrung commented Nov 21, 2024

Rebased on master.

@Secrus
Copy link
Collaborator

Secrus commented Nov 21, 2024

Thank you for the fix

@Secrus Secrus merged commit b84b976 into python-pendulum:master Nov 21, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to build pendulum for 32bit
2 participants